KodNest - Student App

We're offlineLeave a message
You are viewing KodNest Classes's screen
  • Fit to Window
  • Original Size
  • Request Remote Control
  • Select a Microphone
  • Same as System
  • Microphone (Realtek(R) Audio)
  • Select a Speaker
  • Same as System
  • Speakers (Realtek(R) Audio)
  • Leave Computer Audio
  • Audio Options
  • Audio Setting
  • Share to Main Session Only
  • Share to Main Session and Breakout Rooms
  • Show Chat Previews
  • Stop Incoming Video
  • Close
  • Pop Out
Meeting Chat
KodNest Classes To EveryoneHosts and Panelists
4:24:50 PM
KC
package com.bubblesort; import java.util.Scanner; public class BubbleSortApp { public static void main(String[] args) { Scanner scan = new Scanner(System.in); //Creating the array System.out.println("Enter the size of an array"); int [] arr = new int[scan.nextInt()]; //Storing the elements in the array System.out.println("Enter "+arr.length+" elements to be stored"); for(int i=0 ; i<=arr.length-1 ; i++) { arr[i] = scan.nextInt(); } //Printing the elements stored in the array before sorting System.out.println("The array elements before sorting are: "); for(int x:arr) { System.out.print(x+" "); } System.out.println(); //Calling bubbleSort method for sorting an array int [] sortedArray = BubbleSort.bubbleSort(arr); //Printing the elements stored in the array after sorting System.out.println("The array elements after sorting are: "); for(int x:sortedArray) { System.out.print(x+" "); } } }
package com.bubblesort; public class BubbleSort { //Method to sort an array using bubbleSort algorithm public static int [] bubbleSort(int [] arr) { int temp; //Traversing through entire array for(int i=0 ; i<=arr.length-2 ; i++) { //Traversing to all the elements in each iteration for(int j=0 ; j<=arr.length-i-2 ; j++) { //Checking whether jth element is greater than next (j+1) element if(arr[j] > arr[j+1]) { //if arr[j]>arr[j+1] then perform swapping temp = arr[j+1]; arr[j+1] = arr[j]; arr[j] = temp; } } } //returning the sorted array return arr; } }
To:
  • KodNest Classes(Host)
  • KodNest Classes(Co-host)
(Direct Message)

Preview
Pause Share
Stop Share
KodNest Classes